/************************************************************************
 * The code is owned by mainframer.cn and Shang Tao
 * Without aproval of mainframer.cn and Shang Tao, removing the copyright
 * infomation is regarded as invassion of proprietary copyright
 ***********************************************************************/
package com.mr.qa.form;

import org.apache.struts.validator.ValidatorForm;

public class BaseForm extends ValidatorForm 
{
	public BaseForm() 
        {
	}
        
        //verification code
        private String vc;
        
        //action parameter
        private String action;	
        
        
        //'Y' means request comes from a opened window
        private String openedWindow;
        
        /** 'user' or 'admin'
        BaseAction needs this paramter to check if the user has been authorized
        to access administrator resources or user resources
        */
        private String resourceType;
        
        public void setVc(String vc)
        {
            this.vc = vc;
        }
        
        public String getVc()
        {
            return vc;
        }

        public void setAction(String action)
        {
            this.action = action;
        }
        
        public String getAction()
        {
            return action;
        }


        public void setResourceType(String resourceType)
        {
            this.resourceType = resourceType;
        }
        
        public String getResourceType()
        {
            return resourceType;
        }

        public void setOpenedWindow(String openedWindow)
        {
            this.openedWindow = openedWindow;
        }
        
        public String getOpenedWindow()
        {
            return openedWindow;
        }
        
        //page inherited from super class and pageSize, resultSize are utilized to navigate
        private int pageSize;
        private int resultSize;

        public void setPageSize(int pageSize)
        {
            if(pageSize > 60)
                this.pageSize = 60;
            else
                this.pageSize = pageSize;
        }
        
        public int getPageSize()
        {
            return pageSize;
        }
        
        public void setResultSize(int resultSize)
        {
            this.resultSize = resultSize;
        }
        
        public int getResultSize()
        {
            return resultSize;
        }
        
        public int getPage()
        {
            if(this.page == 0)return 1;
            else
            return this.page;
        }
        

    /**
     * 2008-8-14 disable the java script to avoid cross site script
     * @param userText
     * @return
     */
    protected String checkText(String userText)
    {
        if(userText == null || userText.trim().length() == 0)return "";
        if(userText.indexOf("<script>") >= 0)
            userText.replaceAll("<script>","<script>");
        return "";
    }

        
}
